package cn.edu.jnu.supershopper;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private TextView textViewHelloWorld;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textViewHelloWorld= findViewById(R.id.textview_helloworld);

        Button buttonChinese=findViewById(R.id.button_chinese);
        Button buttonEnglish=findViewById(R.id.button_english);

        ButtonClickListener buttonClickListener = new ButtonClickListener();
        buttonEnglish.setOnClickListener(buttonClickListener);
        buttonChinese.setOnClickListener(buttonClickListener);
    }

    private class ButtonClickListener implements View.OnClickListener {
        @Override
        public void onClick(View clickedButtonView) {
            textViewHelloWorld.setText(((Button)clickedButtonView).getText());
            Toast.makeText(MainActivity.this,textViewHelloWorld.getText(),Toast.LENGTH_LONG).show();
        }
    }
}